#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int arr[N];
int b[N];
int n, m;
int main()
{
	cin >> m >> n;
	for (int i = 1; i <= m; i++)cin >> arr[i];
	for (int i = 1; i <= n; i++)cin >> b[i];
	sort(arr + 1, arr + m + 1);
	LL ans = 0;
	for (int i = 1; i <= n; i++) {
		int l = 0, r = m + 1;
		LL ans1 = 0, ans2 = 0;
		LL idx1 = -1, idx2 = -1;
		while (l + 1 < r) {
			int mid = l + r >> 1;
			if (arr[mid] < b[i])l = mid;
			else r = mid;
		}
		//cout << "arr[r]==" << arr[r] << endl;
		idx1 = arr[r];
		ans1 = arr[r] - b[i];
		l = 0, r = m + 1;
		while (l + 1 < r) {
			int mid = l + r >> 1;
			if (arr[mid] <= b[i])l = mid;
			else r = mid;
		}
		//cout << "l==" << r << endl;
		//cout << "arr[l]==" << arr[l] << endl;
		ans2 = b[i] - arr[l]; 
		//idx2 = arr[r];
		//cout << "idx1==" << idx1 << endl;
		//cout << "idx2==" << idx2 << endl;
		/*if (idx1 == idx2) {
			ans += idx1;
			continue;
		}*/
		//cout << "ans1==" << ans1 << endl;
		//cout << "ans2==" << ans2 << endl;
		if (ans1 != -1 && ans2 != -1) 	ans += min(ans1, ans2);
		else {
			if (ans1 == -1)ans += ans2;
			else if (ans2 == -1)ans += ans1;
			else continue;
		}
	}
	cout << ans << endl;
	return 0;
}